﻿using System;
using System.Windows.Forms;

namespace NExplorer.Controls
{
	internal class ExplorerMenuItem : ToolStripMenuItem
	{
		private readonly ToolStripItemCommandManager _manager;

		public ExplorerMenuItem(ICommand command)
		{
			_manager = new ToolStripItemCommandManager(this, command);
		}

		public ExplorerMenuItem(ICommand command, Keys shortcut)
		{
			_manager = new ToolStripItemCommandManager(this, command);
			ShortcutKeys = shortcut;
		}

		public ICommand Command
		{
			get { return _manager.Command; }	
		}

		protected override void OnClick(EventArgs e)
		{
			base.OnClick(e);

			_manager.ExecuteCommand();
		}

		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);

			_manager.Dispose();
		}
	}
}
